<html>
  <script>
    var gui = require('nw.gui');
    
    var win = gui.Window.get();
    
    // mimicks tray menu behaviour, disappears when losing focus
    win.on('blur', function() {
      win.hide();
    });
  </script>
  <body>
    <p>A custom tray menu</p>
    <p><button onclick="win.hide();">Close Menu</button></p>
    <p><button onclick="gui.App.closeAllWindows();">Close App</button></p>
  </body>
</html>